<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author:LJQ <liujiqi@etrol.com>
// +-----------------------------------------------------------------------

namespace app\duty\model;

use app\common\model\Base;
use app\basic\model\Staff;
use app\basic\model\Enterprise;
/**
 * 值班管理
 */
class Position extends Base{
	

	protected $name = 'dutyscheduling';
	protected $createTime = 'createTime';
	protected $updateTime = 'updateTime';
	
	public $postionTypeList=[] ;

	public  function getType(){

	 $postionType=db('basicinfo')->where(array('sysCode'=>28))->column('subsystemName','subsystemNo');
	 $this->postionTypeList=$postionType;
	 return $this->postionTypeList;
	}

	public function getStartDateAttr($value,$data){
		if($data['startDate']){
			return date('Y-m-d H:i:s');
		}
	}


	public function getEndDateAttr($value,$data){
		if($data['endDate']){
			return date('Y-m-d H:i:s');
		}
	}


	public function getdutyWayAttr($value,$data){
		$this->getType();
		if($data['dutyWay']){
			return $this->postionTypeList[$data['dutyWay']];
		}
		return null;
	}

	public function staff() {
		return $this->hasOne(Staff::class,'id','chargePerson');
	}


	public function enterprise() {
		return $this->hasOne(Enterprise::class,'id','enterpriseId');
	}
}